package com.hundredapp.oa.web.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.hundredapp.oa.repository.UserManager;
import com.hundredapp.oa.vo.MenuItem;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@Repository
@Scope("prototype")
public class GetMenu extends ActionSupport{
	
	private List<MenuItem> children;

	public List<MenuItem> getChildren() {
		return children;
	}

	public void setChildren(List<MenuItem> children) {
		this.children = children;
	}

	@Autowired
	private UserManager userManager;
	
	public String execute(){
		Map<String, Object> session_map=ActionContext.getContext().getSession();
		if(session_map.get("lgoin_user_id")!=null){
			int id=Integer.parseInt(session_map.get("lgoin_user_id").toString());
			children=userManager.findMenu(id);
		}
		return SUCCESS;
	}

	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}
}
